package com.central.apps.handler.base;

import com.central.app.common.base.BaseHandler;
import com.central.app.service.HandlerService;
import com.central.common.auth.details.LoginAppUser;
import com.central.common.util.SysUserUtil;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class LvBaseHandler extends BaseHandler {

	@Autowired
	private HandlerService handlerService;
    /**
     * 新建主表及子表时添加默认值
     *
     * @param app
     * @return
     */
    public void addDefault(String app, String object, Map<String, Object> defaultData) throws Exception {

			//获取登录用户信息
			LoginAppUser loginAppUser = SysUserUtil.getLoginAppUser();
			List<Map<String, Object>> mapList = handlerService.findBySql("select fullname from sys_dept where code = '" + loginAppUser.getDeptcode() + "'");
			//运营中心
			defaultData.put("deptcode", loginAppUser.getDeptcode());
			//运营单位描述
			defaultData.put("deptEnity_fullname", MapUtils.getString(mapList.get(0), "fullname"));

    }

}
